/**
 * Created by wenchuan.li on 2018/7/12 14:23.
 */
define(function () {

    var self,vue,
        app = win.app,
        orderSubmitArg,
        g_pgx = [] //评估项列表
    ;

    var Gjpgx = app.Module.extend({

        init: function () {
            self = this;
            self._super({
                _readyBefore: function () {
                    orderSubmitArg = app.pageParameters['gwaq553gjpgx_page'];
                }
            }, win);

        },
        getPgx: function () {//评估项列表
            app.ajax({
                xurl: "api/wx/gwa/getGjpgx",
                // xtime:'2h',
                ocache:true,
                cb: function (result) {
                    if (result.ok) {
                        var data = result.data.data;
                        g_pgx.pushArray(data, true);
                        self.getPgx1();
                    }
                }
            });
        },
        getPgx1: function () {//根据主题+客户获取已有的 评估值
            app.ajax({
                xurl: "api/wx/gwaq553/getPgx",
                xdata:{
                    GWBLID: orderSubmitArg.GWBHID,
                    GWBLNAME:orderSubmitArg.GWBHNAME
                },
                cb: function (result) {
                    if (result.ok) {
                        var data = result.data.data;
                        for(var i=0;i<g_pgx.length;i++){
                            for(var j=0;j<data.length;j++){
                                if(g_pgx[i].GWBC001==data[j].GWBL001){
                                    g_pgx[i].ischecked = true;
                                }else{
                                    g_pgx[i].ischecked = false;
                                }
                            }
                        }
                        // vue.pgx = g_pgx;
                        vue = new Vue({
                            el: app.getByid(doc,'mainNumber'),
                            data: {
                                pgx: g_pgx
                            },
                            methods: {

                            }
                        });
                        data.forEach(function (p1, p2, p3) {
                            g_pgx.filterKV({GWBC001: p1.GWBL001}).addMap({ischecked:true}, true);
                        });
                    }
                }
            });
        },
        _lazy: function () {
            this._super();
            self.getPgx();
        },
        _ready: function () {


            mui('.mui-scroll-wrapper').scroll({
                deceleration: 0.0005
            });
        }
    });

    new Gjpgx();

});